package com.wcs.exam.controller.auth;

import com.wcs.exam.common.base.Result;
import com.wcs.exam.controller.auth.biz.AuthUserAttendanceBiz;
import com.wcs.exam.controller.auth.req.AuthUserAttendanceCheckReq;
import com.wcs.exam.controller.auth.req.AuthUserAttendanceDetectAuthUrlReq;
import com.wcs.exam.controller.auth.req.AuthUserAttendanceInfoReq;
import com.wcs.exam.controller.auth.resp.AuthUserAttendanceAppParamsResp;
import com.wcs.exam.controller.auth.resp.AuthUserAttendanceCheckResp;
import com.wcs.exam.controller.auth.resp.AuthUserAttendanceDetectAuthUrlResp;
import com.wcs.exam.controller.auth.resp.AuthUserAttendanceInfoResp;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * Auth-用户考勤
 *
 * @author wcs
 * @since 2025-03-13
 */
@Tag(name = "Auth-用户考勤")
@RestController
@RequiredArgsConstructor
@RequestMapping("/v1/auth/user/attendance")
public class AuthUserAttendanceController {

    @NotNull
    private final AuthUserAttendanceBiz biz;

    @Operation(summary = "考勤信息查询", description = "用于查询对应业务场景的考勤信息（例如：是否开启打卡，打卡次数，打卡方式等）")
    @GetMapping(value = "/info")
    public Result<AuthUserAttendanceInfoResp> info(@ModelAttribute @Valid AuthUserAttendanceInfoReq req) {
        return biz.info(req);
    }

    @Operation(summary = "App人脸识别", description = "适用于APP场景，答题前人脸身份验证使用")
    @GetMapping(value = "/app/params")
    public Result<AuthUserAttendanceAppParamsResp> appParams() {
        return biz.appParams();
    }

    @Operation(summary = "H5人脸识别", description = "适用于H5场景，答题前人脸身份验证使用")
    @GetMapping(value = "/detect/auth/url")
    public Result<AuthUserAttendanceDetectAuthUrlResp> detectAuthUrl(@ModelAttribute @Valid AuthUserAttendanceDetectAuthUrlReq req) {
        return biz.detectAuthUrl(req);
    }

    @Operation(summary = "考勤校验", description = "用于校验打卡是否成功")
    @PostMapping(value = "/check")
    public Result<AuthUserAttendanceCheckResp> check(@RequestBody @Valid AuthUserAttendanceCheckReq req) {
        return biz.check(req);
    }

}
